home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
dev
/
obero
/
oberon_lib.lha
/
oberon-a
/
source1.lha
/
source
/
Amiga
/
Commodities.mod
< prev
next >
Wrap
Text File
|
1994-08-08
|
13KB
|
472 lines
(***************************************************************************
$RCSfile: Commodities.mod $
Description: Interface to commodities.library
Created by: fjc (Frank Copeland)
$Revision: 3.2 $
$Author: fjc $
$Date: 1994/08/08 00:57:41 $
Includes Release 40.15
(C) Copyright 1985-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A interface Copyright © 1994, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
MODULE Commodities;
(*
** $C- CaseChk $I- IndexChk $L+ LongAdr $N- NilChk
** $P- PortableCode $R- RangeChk $S- StackChk $T- TypeChk
** $V- OvflChk $Z- ZeroVars
*)
IMPORT E := Exec, IE := InputEvent, KM := KeyMap, SYS := SYSTEM;
(**-- Pointer declarations ---------------------------------------------*)
TYPE
NewBrokerPtr * = CPOINTER TO NewBroker;
InputXpressionPtr * = CPOINTER TO InputXpression;
IXPtr * = CPOINTER TO IX;
CxObjPtr * = CPOINTER TO CxObj;
CxMsgPtr * = CPOINTER TO CxMsg;
(*
** $VER: commodities.h 38.4 (24.2.93)
**
** Commodities definitions.
*)
(*****************************************************************************)
TYPE
NewBroker * = RECORD
version * : SHORTINT; (* Must be set to NB_VERSION *)
name * : E.STRPTR;
title * : E.STRPTR;
descr * : E.STRPTR;
unique * : E.WSET;
flags * : E.WSET;
pri * : SHORTINT;
port * : E.MsgPortPtr;
reservedChannel * : INTEGER;
END;
CONST
(* constant for NewBroker.version *)
nbVersion * = 5; (* Version of NewBroker structure *)
(* Sizes for various buffers *)
cbdNamelen * = 24;
cbdTitlelen * = 40;
cbdDescrlen * = 40;
(* Flags for NewBroker.unique *)
nbuDuplicate * = 0;
nbuUnique * = 1; (* will not allow duplicates *)
nbuNotify * = 2; (* sends cxmUnique to existing broker *)
(* Flags for NewBroker.flags *)
cofShowHide * = 4;
(*****************************************************************************)
TYPE
(* Fake data types for system private objects *)
CxObj = RECORD END;
CxMsg = RECORD END;
(* Pointer to a function returning a LONG *)
PFL = PROCEDURE () : LONGINT;
(*****************************************************************************)
CONST
(* Commodities object types *)
invalid * = 0; (* not a valid object (probably null) *)
filter * = 1; (* input event messages only *)
typeFilter * = 2; (* obsolete, do not use *)
send * = 3; (* sends a message *)
signal * = 4; (* sends a signal *)
translate * = 5; (* translates input event into chain *)
broker * = 6; (* application representative *)
debug * = 7; (* dumps info to serial port *)
custom * = 8; (* application provides function *)
zero * = 9; (* system terminator node *)
(*****************************************************************************)
CONST
(* Commodities message types *)
mIEvent * = 32;
mCommand * = 64;
(* Only mIEvent messages are passed through the input network. Other types
* of messages are sent to an optional port in your broker. This means that
* you must test the message type in your message handling, if input messages
* and command messages come to the same port.
*
* mIEvent: Messages of this type rattle around the Commodities input
* network. They are sent to you by a Sender object, and passed
* to you as a synchronous function call by a Custom object.
*
* The message port or function entry point is stored in the
* object, and the ID field of the message will be set to what
* you arrange issuing object.
*
* The data section of the message will point to the input event
* triggering the message.
*
* mCommand: These messages are sent to a port attached to your Broker.
* They are sent to you when the controller program wants your
* program to do something. The ID value identifies the command.
*)
CONST
(* ID values associated with a message of type mCommand *)
cmdDisable * = 15; (* please disable yourself *)
cmdEnable * = 17; (* please enable yourself *)
cmdAppear * = 19; (* open your window, if you can *)
cmdDisappear * = 21; (* go dormant *)
cmdKill * = 23; (* go away for good *)
cmdListChg * = 27; (* Someone changed the broker list *)
cmdUnique * = 25; (* someone tried to create a broker
* with your name. Suggest you appear.
*)
(*****************************************************************************)
TYPE
InputXpression * = RECORD
version * : E.UBYTE; (* must be set to ixVersion *)
class * : E.UBYTE; (* class must match exactly *)
code * : E.WSET; (* Bits that we want *)
codeMask * : E.WSET; (* Set bits here to indicate which bits in code
* are don't care bits.
*)
qualifier * : E.WSET; (* Bits that we want *)
qualMask * : E.WSET; (* Set bits here to indicate which bits in
* qualifier are don't care bits
*)
qualSame * : E.WSET; (* synonyms in qualifier *)
END;
IX * = InputXpression;
CONST
(* constant for InputXpression.version *)
ixVersion * = 2;
(* constants for InputXpression.qualSame *)
ixsymShift * = 0; (* left- and right- shift are equivalent *)
ixsymCaps * = 1; (* either shift or caps lock are equivalent *)
ixsymAlt * = 2; (* left- and right- alt are equivalent *)
ixsymShiftMask * = {IE.qualLShift, IE.qualRShift};
ixsymCapsMask * = ixsymShiftMask + {IE.qualCapsLock};
ixsymAltMask * = {IE.qualLAlt, IE.qualRAlt};
(* constant for InputXpression.qualMask *)
ixNormalQuals * = {0..14}; (* avoid RELATIVEMOUSE *)
(*****************************************************************************)
CONST
(* Error returns from CxBroker() *)
cbErrOk * = 0; (* No error *)
cbErrSysErr * = 1; (* System error, no memory, etc *)
cbErrDup * = 2; (* uniqueness violation *)
cbErrVersion * = 3; (* didn't understand NewBroker.nb_Version *)
(*****************************************************************************)
CONST
(* Return values from CxObjError() *)
coErrIsNull * = 1; (* you called CxObjError(NULL) *)
coErrNullAttach * = 2; (* someone attached NULL to my list *)
coErrBadFilter * = 4; (* a bad filter description was given *)
coErrBadType * = 8; (* unmatched type-specific operation *)
(*****************************************************************************)
(**-- Library Base variable --------------------------------------------*)
TYPE
CommoditiesBasePtr * = CPOINTER TO CommoditiesBase;
CommoditiesBase * = RECORD (E.Library) END;
CONST
name * = "commodities.library";
VAR
base * : CommoditiesBasePtr;
(**-- Library Functions ------------------------------------------------*)
(*
** $VER: commodities_protos.h 38.4 (27.2.92)
*)
TYPE
CustomProcType * = PROCEDURE ( obj : CxObjPtr; msg : CxMsgPtr );
(* --- functions in V36 or higher (distributed as Release 2.0) ---*)
(* OBJECT UTILITIES *)
LIBCALL (base : CommoditiesBasePtr) CreateCxObj*
( type [0] : E.ULONG;
arg1 [8] : SYS.LONGWORD;
arg2 [9] : SYS.LONGWORD )
: CxObjPtr;
-30;
LIBCALL (base : CommoditiesBasePtr) CxBroker*
( VAR nb [8] : NewBroker;
VAR error [0] : LONGINT )
: CxObjPtr;
-36;
LIBCALL (base : CommoditiesBasePtr) ActivateCxObj*
( co [8] : CxObjPtr;
true [0] : E.LBOOL )
: E.LBOOL;
-42;
LIBCALL (base : CommoditiesBasePtr) DeleteCxObj*
( co [8] : CxObjPtr );
-48;
LIBCALL (base : CommoditiesBasePtr) DeleteCxObjAll*
( co [8] : CxObjPtr );
-54;
LIBCALL (base : CommoditiesBasePtr) CxObjType*
( co [8] : CxObjPtr )
: E.ULONG;
-60;
LIBCALL (base : CommoditiesBasePtr) CxObjError*
( co [8] : CxObjPtr )
: SET;
-66;
LIBCALL (base : CommoditiesBasePtr) ClearCxObjError*
( co [8] : CxObjPtr );
-72;
LIBCALL (base : CommoditiesBasePtr) SetCxObjPri*
( co [8] : CxObjPtr;
pri [0] : LONGINT )
: LONGINT;
-78;
(* OBJECT ATTACHMENT *)
LIBCALL (base : CommoditiesBasePtr) AttachCxObj*
( headObj [8] : CxObjPtr;
co [9] : CxObjPtr );
-84;
LIBCALL (base : CommoditiesBasePtr) EnqueueCxObj*
( headObj [8] : CxObjPtr;
co [9] : CxObjPtr );
-90;
LIBCALL (base : CommoditiesBasePtr) InsertCxObj*
( headObj [8] : CxObjPtr;
co [9] : CxObjPtr;
pred [10] : CxObjPtr );
-96;
LIBCALL (base : CommoditiesBasePtr) RemoveCxObj*
( co [8] : CxObjPtr );
-102;
(* TYPE SPECIFIC *)
LIBCALL (base : CommoditiesBasePtr) SetTranslate*
( translator [8] : CxObjPtr;
VAR events [9] : IE.InputEvent );
-114;
LIBCALL (base : CommoditiesBasePtr) SetFilter*
( filter [8] : CxObjPtr;
text [9] : ARRAY OF CHAR );
-120;
LIBCALL (base : CommoditiesBasePtr) SetFilterIX*
( filter [8] : CxObjPtr;
VAR ix [9] : IX );
-126;
LIBCALL (base : CommoditiesBasePtr) ParseIX*
( description [8] : ARRAY OF CHAR;
VAR ix [9] : IX )
: LONGINT;
-132;
(* COMMON MESSAGE *)
LIBCALL (base : CommoditiesBasePtr) CxMsgType*
( cxm [8] : CxMsgPtr )
: SET;
-138;
LIBCALL (base : CommoditiesBasePtr) CxMsgData*
( cxm [8] : CxMsgPtr )
: E.APTR;
-144;
LIBCALL (base : CommoditiesBasePtr) CxMsgID*
( cxm [8] : CxMsgPtr )
: LONGINT;
-150;
(* MESSAGE ROUTING *)
LIBCALL (base : CommoditiesBasePtr) DivertCxMsg*
( cxm [8] : CxMsgPtr;
headobj [9] : CxObjPtr;
ret [10] : CxObjPtr );
-156;
LIBCALL (base : CommoditiesBasePtr) RouteCxMsg*
( cxm [8] : CxMsgPtr;
co [9] : CxObjPtr );
-162;
LIBCALL (base : CommoditiesBasePtr) DisposeCxMsg*
( cxm [8] : CxMsgPtr );
-168;
(* INPUT EVENT HANDLING *)
LIBCALL (base : CommoditiesBasePtr) InvertKeyMap*
( ansicode [0] : E.ULONG;
event [8] : IE.InputEventBasePtr;
km [9] : KM.KeyMapPtr )
: BOOLEAN;
-174;
LIBCALL (base : CommoditiesBasePtr) AddIEvents*
( events [8] : IE.InputEventBasePtr );
-180;
(*--- functions in V38 or higher (Release 2.1) ---*)
(* MORE INPUT EVENT HANDLING *)
LIBCALL (base : CommoditiesBasePtr) MatchIX *
( event [8] : IE.InputEventBasePtr;
ix [9] : IXPtr )
: BOOLEAN;
-204;
(**-- C Macros defined as procedures -----------------------------------*)
(** $L+ Absolute long addressing for globals *)
(*************************
* object creation macros
*************************)
(**-----------------------------------*)
PROCEDURE CxFilter *
(base : CommoditiesBasePtr; d : E.STRPTR)
: CxObjPtr;
BEGIN (* CxFilter *)
RETURN base.CreateCxObj (filter, d, NIL)
END CxFilter;
(**-----------------------------------*)
PROCEDURE CxTypeFilter *
(base : CommoditiesBasePtr; type : LONGINT)
: CxObjPtr;
BEGIN (* CxTypeFilter *)
RETURN base.CreateCxObj (typeFilter, type, NIL)
END CxTypeFilter;
(**-----------------------------------*)
PROCEDURE CxSender *
(base : CommoditiesBasePtr; port : E.MsgPortPtr; id : LONGINT)
: CxObjPtr;
BEGIN (* CxSender *)
RETURN base.CreateCxObj (send, port, id)
END CxSender;
(**-----------------------------------*)
PROCEDURE CxSignal *
(base : CommoditiesBasePtr; task : E.TaskPtr; sig : LONGINT)
: CxObjPtr;
BEGIN (* CxSignal *)
RETURN base.CreateCxObj (signal, task, sig)
END CxSignal;
(**-----------------------------------*)
PROCEDURE CxTranslate *
(base : CommoditiesBasePtr; ie : IE.InputEventBasePtr)
: CxObjPtr;
BEGIN (* CxTranslate *)
RETURN base.CreateCxObj (translate, ie, NIL)
END CxTranslate;
(**-----------------------------------*)
PROCEDURE CxDebug *
(base : CommoditiesBasePtr; id : LONGINT)
: CxObjPtr;
BEGIN (* CxDebug *)
RETURN base.CreateCxObj (debug, id, NIL)
END CxDebug;
(**-----------------------------------*)
PROCEDURE CxCustom *
(base : CommoditiesBasePtr; action : CustomProcType; id : E.APTR)
: CxObjPtr;
BEGIN (* CxCustom *)
RETURN base.CreateCxObj (custom, action, id)
END CxCustom;
(**-- Library Base variable --------------------------------------------*)
(** $L- Address globals through A4 *)
(**-----------------------------------*)
PROCEDURE* CloseLib ();
BEGIN (* CloseLib *)
IF base # NIL THEN E.base.CloseLibrary (base) END;
END CloseLib;
(**-----------------------------------*)
PROCEDURE OpenLib * (mustOpen : BOOLEAN);
BEGIN (* OpenLib *)
IF base = NIL THEN
base :=
SYS.VAL
( CommoditiesBasePtr,
E.base.OpenLibrary (name, E.libraryMinimum) );
IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
ELSIF mustOpen THEN HALT (100)
END;
END;
END OpenLib;
BEGIN
base := NIL
END Commodities.